﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

using Gift.DAL;

namespace WebSite.cn
{
    public partial class InstitutionMenu : System.Web.UI.UserControl
    {
        StringBuilder strServerList = new StringBuilder();
        DALInstitution theInstitution = new DALInstitution();
        string sLiHTML = "<a id=\"menu{0}\" class=\"menuitem\"  onclick=\"change_bg(this);getRightDetail('divRightContent','InstitutionCardList.aspx?id={1}&dt={3}');\" >{2}</a>";


        public string ServerList
        {
            get
            {
                return strServerList.ToString();
            }
        }

        public string HoverColor
        {
            get
            {
                return "#fff";
              
            }
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.BindServerList();
                this.BindSelectMenuStyle();
            }
        }

        void BindServerList()
        {
            Dictionary<int, string> dicInstitutionMenu = new Dictionary<int, string>();
            dicInstitutionMenu = theInstitution.GetInstitutionMenuList();
       
            foreach (int key in dicInstitutionMenu.Keys)
            {
                strServerList.Append(string.Format(sLiHTML, key.ToString(), key.ToString(), dicInstitutionMenu[key], DateTime.Now.Ticks.ToString()));
            }

        }

        void BindSelectMenuStyle()
        {
            string myScript = @"change_bg(document.getElementById('menu0'));";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", myScript, true);

            string myMenu = @"getRightDetail('divRightContent','InstitutionCardList.aspx?id=0');";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "myMenu", myMenu, true);
        }
    }
}